package com.arpa.wms.controller.wms;


import com.arpa.core.web.Result;
import com.arpa.ntocc.common.common.constant.StrConsts;
import com.arpa.ntocc.common.security.annotation.NeedLogin;
import com.arpa.wms.domain.dto.PrepackagedItemDTO;
import com.arpa.wms.domain.vo.PrepackagedItemVO;
import com.arpa.wms.service.IPrepackagedItemService;
import com.arpa.wms.service.IPrepackagedService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 预打包明细 前端控制器
 * </p>
 *
 * @author rfwang
 * @since 2021年7月5日
 */
@Api(tags = "预打包明细")
@RestController
@NeedLogin
@RequestMapping("/prepackagedItem")
@Log4j2
public class PrepackagedItemController {

    @Autowired
    private IPrepackagedItemService prepackagedItemService;
    /**
     * 获取 预打包明细可用存库
     *
     * @param prepackagedItemDTO
     * @param request
     * @return
     */
    @ApiOperation(value = "获取 预打包明细可用存库", notes = "获取 预打包明细可用存库")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "授权token", required = true, paramType = "header", dataType = "String", defaultValue = "Bearer 123456"),
            @ApiImplicitParam(name = "deviceId", value = "设备id", paramType = "header", dataType = "string", defaultValue = "0000000000"),
            @ApiImplicitParam(name = "goodsCode", value = "商品code", required = true,paramType = "path", dataType = "String"),
            @ApiImplicitParam(name = "warehouseCode", value = "仓库编码", required = true,paramType = "path", dataType = "String"),
            @ApiImplicitParam(name = "shipmentCode", value = "货主编码", required = true,paramType = "path", dataType = "String")
    })
    @ApiResponses(@ApiResponse(code = 0, message = "success", response = PrepackagedItemVO.class))
    @NeedLogin
    @GetMapping(value = "/queryUsefulInventory")
    public Result queryInventory(PrepackagedItemDTO prepackagedItemDTO, HttpServletRequest request) {
        try {
            return prepackagedItemService.queryInventory(prepackagedItemDTO);
        } catch (Exception e) {
            log.error(StrConsts.CATCH_MESSAGE,e);
            return Result.error(e.getMessage());
        }
    }
}
